Skip to content

feat(tools): add ReadMediaFile tool for image/video files#661

Merged
stdrc merged 5 commits into
mainfrom
rc/read-file-split
Jan 21, 2026
Merged

feat(tools): add ReadMediaFile tool for image/video files#661
stdrc merged 5 commits into
mainfrom
rc/read-file-split

Conversation

@stdrc

@stdrc stdrc commented Jan 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Add a dedicated ReadMediaFile tool for reading image and video files, separating media file handling from the ReadFile tool which now focuses exclusively on text files.

Changes

New Tool: ReadMediaFile

  • Dedicated tool for reading image/video files
  • Max file size: 100MB
  • Only available when the model supports image/video input (image_in/video_in capabilities)
  • Returns image dimensions when available (via PIL)
  • Uploads videos to Kimi Files API when using Kimi provider

Updated Tool: ReadFile

  • Now focuses exclusively on text files
  • Returns an error when attempting to read image/video files, directing users to use ReadMediaFile
  • Simplified implementation with media handling code removed

Other Changes

  • Added ReadMediaFile to default and okabe agent configurations
  • Added comprehensive tests for the new tool
  • Updated documentation (changelog, agents reference) in both Chinese and English

stdrc added 5 commits January 21, 2026 18:32
Signed-off-by: Richard Chien <stdrc@outlook.com>
Signed-off-by: Richard Chien <stdrc@outlook.com>
Signed-off-by: Richard Chien <stdrc@outlook.com>
Signed-off-by: Richard Chien <stdrc@outlook.com>
Signed-off-by: Richard Chien <stdrc@outlook.com>
Copilot AI review requested due to automatic review settings January 21, 2026 11:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a dedicated ReadMediaFile tool for reading image and video files, separating media file handling from the ReadFile tool which now focuses exclusively on text files.

Changes:

  • Added new ReadMediaFile tool with 100MB max file size, capability-based availability, and image dimension detection
  • Updated ReadFile to reject image/video files and redirect users to use appropriate tools
  • Added comprehensive test coverage and updated documentation in both English and Chinese

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/kimi_cli/tools/file/read_media.py New tool implementation for reading image/video files with capability checks and Kimi-specific video upload support
src/kimi_cli/tools/file/read_media.md Tool description template with dynamic capability-based instructions
src/kimi_cli/tools/file/read.py Removed media handling code, now returns errors for image/video files
src/kimi_cli/tools/file/read.md Updated description to clarify text-only focus
src/kimi_cli/tools/file/__init__.py Added ReadMediaFile to exports
src/kimi_cli/tools/__init__.py Added ReadMediaFile to key argument extraction
src/kimi_cli/agents/default/agent.yaml Added ReadMediaFile to default agent tools
src/kimi_cli/agents/okabe/agent.yaml Added ReadMediaFile to okabe agent tools
tests/test_read_media_file.py Comprehensive tests for the new tool
tests/test_read_media_file_desc.py Tests for capability-based descriptions
tests/test_read_file.py Updated tests to expect errors for media files
tests/test_read_file_desc.py Removed (old capability-based description tests)
tests/conftest.py Added fixture for ReadMediaFile tool
tests/test_tool_schemas.py Added schema test for ReadMediaFile
tests/test_tool_descriptions.py Updated descriptions for both tools
tests/test_default_agent.py Updated default agent test with ReadMediaFile
tests/test_agent_spec.py Added ReadMediaFile to agent specifications
tests/test_pyinstaller_utils.py Added ReadMediaFile to PyInstaller configuration
docs/zh/customization/agents.md Updated Chinese documentation with ReadMediaFile
docs/en/customization/agents.md Updated English documentation with ReadMediaFile
docs/zh/release-notes/changelog.md Added changelog entry in Chinese
docs/en/release-notes/changelog.md Added changelog entry in English
CHANGELOG.md Added changelog entry
src/kimi_cli/acp/AGENTS.md Added note about ReadMediaFile ACP integration
klips/klip-12-wire-initialize-external-tools.md Updated KLIP status to Implemented

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_read_file.py
assert part.image_url.url.startswith("data:image/png;base64,")
assert result.is_error
assert result.message == snapshot(
f"`{image_file}` is a image file. Use other appropriate tools to read image or video files."

Copilot AI Jan 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar error: "is a image" should be "is an image" because "image" starts with a vowel sound.

Copilot uses AI. Check for mistakes.
Comment thread tests/test_read_file.py
assert part.image_url.url.startswith("data:image/png;base64,")
assert result.is_error
assert result.message == snapshot(
f"`{image_file}` is a image file. Use other appropriate tools to read image or video files."

Copilot AI Jan 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar error: "is a image" should be "is an image" because "image" starts with a vowel sound.

Copilot uses AI. Check for mistakes.
return ToolError(
message=(
f"`{path}` is {size} bytes, which exceeds the max "
f"{MAX_MEDIA_MEGABYTES}MB bytes for media files."

Copilot AI Jan 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent error message format. The error message says "{MAX_MEDIA_MEGABYTES}MB bytes" which is redundant. It should be either "{MAX_MEDIA_MEGABYTES}MB" or "{MAX_MEDIA_MEGABYTES << 20} bytes" to match the style in the comparison.

Suggested change
f"{MAX_MEDIA_MEGABYTES}MB bytes for media files."
f"{MAX_MEDIA_MEGABYTES << 20} bytes for media files."

Copilot uses AI. Check for mistakes.

from kaos.path import KaosPath
from kosong.chat_provider.kimi import Kimi
from kosong.tooling import CallableTool2, ToolError, ToolOk, ToolReturnValue

Copilot AI Jan 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'CallableTool2' is not used.

Copilot uses AI. Check for mistakes.
@stdrc
stdrc merged commit 628afeb into main Jan 21, 2026
17 checks passed
@stdrc
stdrc deleted the rc/read-file-split branch January 21, 2026 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants